package message

import (
	"context"
	"errors"
	"gitee.com/arjunxw/iothub-south-client/service"
)

type CheckStatusHandler struct {
	dalInfoService service.DalInfoService
}

func NewCheckStatusHandler(dalInfoService service.DalInfoService) IotHubMessageHandler {
	return &CheckStatusHandler{dalInfoService: dalInfoService}
}

func (csh *CheckStatusHandler) NotifyType() string {
	return NotifyCheckStatus
}

func (csh *CheckStatusHandler) Handle(downstream *Downstream) error {
	dalInfo := csh.dalInfoService.FindByDalId(context.Background(), downstream.DalID)
	if dalInfo == nil {
		return errors.New("unsupported dal, dalId: " + downstream.DalID)
	}
	return nil
}
